#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#define N 20
void swap(int* a, int* b)
{
    int tmp = 0;
    tmp = *a;
    *a = *b;
    *b = tmp;
}
int main()
{
    int a[N]={0}, * p, i;
    int n;
    scanf("%d", &n);
    p = a;
    for (p = a; p < a + n; p++)
    {
        scanf("%d", p);
    }
    int begin = 0;
    int end = n - 1;
    while (begin < end)
    {
        int min = begin, max = begin;
        for (i = begin + 1;i <= end;i++)
        {
            if (a[i] < a[min])
            {
                min = i;
            }
            if (a[i] > a[max])
            {
                max = i;
            }
        }
        swap(&a[begin], &a[min]);
        if (max == begin)
        {
            max = min;
        }
        swap(&a[end], &a[max]);
        begin++;
        end--;
    }

    for (p = a; p < a + n; p++)
    {
        printf("%d ", *p);
    }
    printf("\n");
    return 0;
}
